feat: openai-compatible deepseek/qwq reasoning support #1566
+15
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Implemented parsing support for think tags output by openai-compatible API.
Similar to PR #1080, not only the deepseek-r1:* models in Ollama use think tags to output reasoning content, but the QwQ model will also use the same approach to output reasoning content. When using vendors like Alibaba Cloud Baolian or VolcEngine, these providers will directly output content containing think tags instead of placing them in the reasoning field. Therefore, it's also necessary for OpenAI-compatible APIs to support processing think tags.
Implementation
Similar to PR #1080, I added XmlMatcher to src/api/providers/openai.ts, and it now works properly.
Screenshots
How to Test
Get in Touch
Important
Adds support for parsing
thinktags in OpenAI-compatible APIs usingXmlMatcherinopenai.tsfor deepseek-r1 and QwQ models.thinktags in OpenAI-compatible APIs for deepseek-r1 and QwQ models.XmlMatcherinOpenAiHandlerinopenai.tsto differentiate between reasoning and text content.XmlMatcherto process streamed content, yielding reasoning or text based onthinktags.createMessage()inOpenAiHandlerto utilizeXmlMatcherfor processing streamed responses.This description was created by
for 7114cef. It will automatically update as commits are pushed.